|
| CuttingEdge.Conditions reference library |
| ValidatorExtensions..::.Evaluate<(Of <(T>)>) Method (ConditionValidator<(Of <(T>)>), Expression<(Of <(Func<(Of <(T, Boolean>)>)>)>)) |
| ValidatorExtensions Class See Also Send Feedback |
Checks whether the specified expression evaluates true on the given value.
An exception is thrown otherwise.
Namespace:
CuttingEdge.Conditions
Assembly:
CuttingEdge.Conditions (in CuttingEdge.Conditions.dll)
Syntax
| Visual Basic (Declaration) |
|---|
Public Shared Function Evaluate(Of T) ( _ validator As ConditionValidator(Of T), _ expression As Expression(Of Func(Of T, Boolean)) _ ) As ConditionValidator(Of T) |
| C# |
|---|
public static ConditionValidator<T> Evaluate<T>( ConditionValidator<T> validator, Expression<Func<T, bool>> expression ) |
| Visual C++ |
|---|
public: generic<typename T> static ConditionValidator<T>^ Evaluate( ConditionValidator<T>^ validator, Expression<Func<T, bool>^>^ expression ) |
| JavaScript |
|---|
JavaScript does not support generic types or methods. |
Parameters
- validator
- Type: CuttingEdge.Conditions..::.ConditionValidator<(Of <(T>)>)
The ConditionValidator<(Of <(T>)>) that holds the value that has to be checked.
- expression
- Type: System.Linq.Expressions..::.Expression<(Of <(Func<(Of <(T, Boolean>)>)>)>)
The Expression<(Of <(TDelegate>)>) that will be compiled to an Func<(Of <(T, TResult>)>) and executed. When the expression is a null reference (Nothing in VB) it is considered to evaluate false.
Type Parameters
- T
- The type of the Value of the specified validator.
Return Value
The specified validator instance.
Remarks
This method will display a string representation of the specified expression.
Although it can therefore give a lot of useful information in the exception message, it the
expression has to be compiled on each
call. Try using the other Evaluate<(Of <(T>)>)(ConditionValidator<(Of <(T>)>), Boolean)
overload in performance sensitive parts of your program.
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentException | Thrown when the expression evaluated false or is a null reference, while the specified validator is created using the Requires extension method. |
| System..::.ArgumentNullException | Thrown when the expression evaluated false or is a null reference and the Value of the specified validator is a null reference, while the specified validator is created using the Requires extension method. |
| System.ComponentModel..::.InvalidEnumArgumentException | Thrown when the expression evaluated false or is a null reference and the Value of the specified validator is an Enum type, while the specified validator is created using the Requires extension method. |
| CuttingEdge.Conditions..::.PostconditionException | Thrown when the expression evaluated false or is a null reference, while the specified validator is created using the Ensures extension method. |